<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .container{
            width: 600px;
            height: 600px;
            background-color: #ccc;
            margin:0 auto;
            display: flex;
            flex-direction: row;
            flex-wrap: nowrap;
        }

        .container div{
            width: 100px;
            height: 100px; 
        }

        .container div:nth-of-type(n){
            background-color: #ff000052;
        }
        .container div:nth-of-type(2n+1){
            background-color: #00ff0052;
        }

        .container div:nth-of-type(3){
            flex-shrink: 0;
        }

        .c2 div:nth-of-type(1){
          flex-grow:1;  
        }

        .c2 div:nth-of-type(2){
          flex-grow:3;  
        }
    </style>
</head>
<body>
    <div class="container">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
        <div>6</div>
        <div>7</div>
        <div>8</div>
    </div>

    <div class="container c2">
        <div>1</div>
        <div>2</div> 
    </div>
</body>
</html>